<?php


namespace App\Model;


use App\Utility\Pool\RedisPool;

class Token
{
    const ALGO = 'ripemd160';
    const TOKEN_KEY = 'i3d6o32wo8fvs1fvdpwens';
    const EXP = 604800;
    const TOKEN_HEADER = 'authorization';
    const JWTKEY = '@#FDGDFGH%$^fdsft436456dsestr4335EWSDFDSH';
    private $redis;

    private $px = 'tp:';

    private $px_id = 'cz_token_id_';


    public function __construct()
    {
        $this->redis = RedisPool::defer();
    }

    public function get($token)
    {
        $uid = intval($this->redis->get($this->px . hash_hmac(self::ALGO, $token, self::TOKEN_KEY)));
        return $uid;
    }


    public function exp($token)
    {
        return $this->redis->ttl($this->px . hash_hmac(self::ALGO, $token, self::TOKEN_KEY));
    }


}